﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.popups.payment {
    import reprise.ui.*;
    import flash.events.*;
    import reprise.controls.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.views.popups.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;

    public class ShopPopupMediator extends AbstractPopupMediator {

        private var _radioGroup:RadioButtonGroup;

        override public function onRegister():void{
            var _local2:Object;
            super.onRegister();
            _popupType = this.view.data.action;
            addOkButton("global_button_ok");
            addLabel("title showcardGothicFont", this.view.data.title);
            var _local1:UIComponent = RepriseUtils.addComponent(this.view, "content");
            for each (_local2 in this.view.data.items) {
                this.addShopItem(_local2, _local1);
            };
        }
        public function addShopItem(_arg1:Object, _arg2:UIComponent):void{
            var _local3:RadioButton = RepriseUtils.addRadioButton(_arg2, "shopItem", "shopPopup");
            _local3.selected = _arg1.selected;
            if (_local3.selected){
                _local3.addCSSClass("highlight");
                addLabel("bestBuy showcardGothicFont", "payment_general_bestvalue", null, _local3);
            };
            _local3.setData(_arg1);
            RepriseUtils.addComponent(_local3, "checkbox");
            this._radioGroup = _local3.group();
            RepriseUtils.addComponent(_local3, "price");
            RepriseUtils.addComponent(_local3, "itemSymbol");
            addLabel("itemAmount showcardGothicFontOutline", "global_number", {number:_arg1.amount}, _local3);
            RepriseUtils.addComponent(_local3, "currencySymbol");
            addLabel("itemCosts text", "payment_general_for", {amount:_arg1.price}, _local3);
        }
        private function get view():ShopPopupView{
            return ((viewComponent as ShopPopupView));
        }
        override protected function onOk(_arg1:MouseEvent):void{
            var _local2:Object = this._radioGroup.selectedRadioButton().data();
            var _local3:Object = {product_id:_local2.product_id, product_type:this.view.data.action, amount:_local2.amount, icon:_local2.icon};
            var _local4:InfoEvent = new InfoEvent(EventConstants.START_PAYMENT, null, _local3);
            dispatch(_local4);
        }

    }
}//package net.wooga.pets.views.popups.payment 
